﻿<Window x:Class="ChronosBuildTool.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ChronosBuildTool"
        Title="Chronos Build" ResizeMode="CanMinimize, NoResize"
        SnapsToDevicePixels="True" SizeToContent="WidthAndHeight">
    <Window.Resources>
        <local:BuildResultToColorConverter x:Key="BuildResultToColorConverter" />
        <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Window.Resources>
    <Grid Width="700">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="400" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="200" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="Configuration: "/>
            <ComboBox Grid.Column="1" ItemsSource="{Binding Configurations}" SelectedItem="{Binding CurrentConfiguration}" />
        </Grid>
        <ListView Grid.Row="1" ItemsSource="{Binding Solutions}" ScrollViewer.VerticalScrollBarVisibility="Visible">
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="25">
                        <GridViewColumn.Header>
                            <CheckBox IsChecked="{Binding DataContext.Solutions.IsChecked, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
                        </GridViewColumn.Header>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{Binding IsChecked}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Solution" DisplayMemberBinding="{Binding SolutionName}"  Width="450" />

                    <GridViewColumn Header="Result">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Border Background="{Binding BuildResult, Converter={StaticResource BuildResultToColorConverter}}" Height="15" Width="15"
                                        BorderBrush="#888888" BorderThickness="1" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn Header="Build Time" DisplayMemberBinding="{Binding BuildResult.Elapsed}" Width="130" />
                    
                </GridView>
            </ListView.View>
        </ListView>
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Content="Build" Command="{Binding BuildCommand}" />
            <Button Grid.Column="1" Content="Rebuild" Command="{Binding RebuildCommand}" />
            <Button Grid.Column="2" Content="Clean" Command="{Binding CleanCommand}" />
            <Button Grid.Column="3" Content="Stop" Command="{Binding StopCommand}" />
            <Button Grid.Column="5" Content="Console" Command="{Binding ShowHideConsoleCommand}" />
        </Grid>
        <TextBox Grid.Row="3" Text="{Binding Output.Text, Mode=OneWay}" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"
                 Visibility="{Binding IsConsoleVisible, Converter={StaticResource BoolToVisibilityConverter}}" Height="300"/>
    </Grid>
</Window>
